<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>fasty</title>

    <script src="fasty.js"></script>

</head>

<body>
<script>

    // var testhtml = "a";
    // var testhtml = "{{~ for(item of array)}} xxx {{~end}}";
    // var testhtml = "{{~ for(item of array)}} xxx  {{~ for (newItem of item.xxx)}} xxxx  {{~end}} {{~end}}";
    // var testhtml = "{{~ for(item of array)}} xxx  {{~ for (newItem of item1.xxx)}} xxxx  {{~end}} {{~end}}";
    // var testhtml = "{{~ for(var x=0;x<100;x++)}}xxx {{~end}}";
    // var testhtml = "{{~ for(var x=0,a=title;x<title.length;x++)}}  xxx{{a}} {{~end}}";
    // var testhtml = "{{~ var aaa = \"aaa\"}}";
    // var testhtml = "{{~ var aaa = \"aaa\"}}   {{~ for ( x of aaa)}}  {{aaa}}--{{x}}--{{end1}}--end {{~end}}";
    // var testhtml = "{{~ var aaa = \"aaa\"}}   {{~ for ( x of aaa)}}  {{aaa}}--{{x}}--{{end1}}--end {{~end}} {{x}} {{aaa}} {{bbb}}";
    // var testhtml = "{{~ var aaa = \"aaa\"}}   {{~ for ( x of aaa)}}  {{aaa}}--{{x}}--{{end1}}--end  {{~for (var i=0;i< x.length;i++)}}  {{x[i]}}  {{~end}} {{~end}} {{x}} {{aaa}} {{bbb}}";
    // var testhtml = "{{~ var aaa = \"aaa\"}}   {{~ for ( x of aaa)}}  {{aaa}}--{{x}}--{{end1}}--end  {{~for (var i=0;i< x.length;i++)}}  {{x[i]}} {{aaa}} {{bbb}} {{~end}} {{~end}} {{x}} {{aaa}} {{bbb}}";
    // var testhtml = "{{~if (a == b)}} xxx {{~end}}";
    // var testhtml = "{{~ var a = \"c\"}} {{~if (a == b)}} xxx {{~end}}";
    // var testhtml = "{{~ var a = \"c\",b=\"c\"}} {{~if (a == b)}} xxx    {{~end}}{{title}}{{content}} {{sexString?(1)}} {{a?.b?.c?().d?}}";
    var testhtml = "{{~ var a =  100}} {{~for (var i=0;i<10;i++)}} {{~ a++}} {{~end}}  {{a}}";

    // var testhtml = '<div class="modal">' +
    //     '  <div class="modal-dialog modal-lg">' +
    //     '    <div class="modal-content shadow-lg">' +
    //     '      <div class="modal-header">' +
    //     '        <h5 class="modal-title">{{title}}</h5>' +
    //     '        <button type="button" class="close" data-dismiss="modal" aria-label="Close" >' +
    //     '          <span aria-hidden="true">&times;</span>' +
    //     '        </button>' +
    //     '      </div>' +
    //     '      <div class="modal-body" style="word-break: break-all">' +
    //     '        <p>{{content}}</p>' +
    //     '      </div>' +
    //     '      <div class="modal-footer">' +
    //     '        <button type="button" class="btn btn-secondary" data-dismiss="modal"> 关闭 </button>' +
    //     '      </div>' +
    //     '    </div>' +
    //     '  </div>' +
    //     '</div>';

    var data = {"title": "title test", "content": "content test..."};
    var fasty = new Fasty({
        share: {
            sexString: function (v) {
                console.log("sexString>>> invoked")
                return v === 0 ? '女' : '男';
            }
        },
        safelyAccess:false,//true
    });

    console.log(fasty.render(testhtml, data))
</script>

</body>

</html>
